import Tess2 from "./tess2.js";

// Define input
var ca = [0,0, 10,0, 5,10].map(val => val * 50);
var cb = [0,2, 10,2, 10,6, 0,6].map(val => val * 50);
var contours = [ca,cb];

const res = Tess2.tesselate({
  contours,
  windingRule: Tess2.WINDING_ODD,
  elementType: Tess2.POLYGONS,
  polySize: 3,
  vertexSize: 2
})
console.log(res)

const canvas = document.querySelector('canvas')
const ctx = canvas.getContext('2d')

const vertices = res.vertices
ctx.moveTo(vertices[0], vertices[1])

for (let i = 2; i < vertices.length; i += 2) {
  ctx.lineTo(vertices[i], vertices[i + 1])
}
// ctx.fill('evenodd')
ctx.stroke()